﻿using log4net;
using StoreProject.Forms.SettingForms;
using StoreProject.Forms.StackForms;
using StoreProject.Forms.StackForms.Operate;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StoreProject.Forms
{
    public partial class StackManageForm : Form
    {
        ILog _log = LogManager.GetLogger("StackManageForm");
        private Dictionary<string, Control> settingDic = null;
        public StackManageForm()
        {
            InitializeComponent();
        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (e.Node != null && Convert.ToInt32(e.Node.Tag) != 0)
                {
                    this.splitContainer1.Panel2.Controls.Clear();
                    this.splitContainer1.Panel2.Controls.Add(settingDic[e.Node.Text]);
                    settingDic[e.Node.Text].Show();
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }

        private void StackManageForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (treeView1.Nodes[0].Nodes[0].IsExpanded == false)
                {
                    treeView1.Nodes[0].ExpandAll();
                }
                #region 设置右侧页面
                settingDic = new Dictionary<string, Control>();

                StackQueryForm stackQueryForm = new StackQueryForm();
                stackQueryForm.TopLevel = false;
                stackQueryForm.Dock = DockStyle.Fill;//把子窗体设置为控件
                stackQueryForm.FormBorderStyle = FormBorderStyle.None;
                settingDic.Add("库存查询", stackQueryForm);

                StackInQueryForm stackInQueryForm = new StackInQueryForm();
                stackInQueryForm.TopLevel = false;
                stackInQueryForm.Dock = DockStyle.Fill;//把子窗体设置为控件
                stackInQueryForm.FormBorderStyle = FormBorderStyle.None;
                settingDic.Add("入库操作", stackInQueryForm);

                StackAllotQueryForm stackAllotQueryForm = new StackAllotQueryForm();
                stackAllotQueryForm.TopLevel = false;
                stackAllotQueryForm.Dock = DockStyle.Fill;//把子窗体设置为控件
                stackAllotQueryForm.FormBorderStyle = FormBorderStyle.None;
                settingDic.Add("调拨及出库操作", stackAllotQueryForm);

                ProductQueryForm productQueryForm = new ProductQueryForm();
                productQueryForm.TopLevel = false;
                productQueryForm.Dock = DockStyle.Fill;//把子窗体设置为控件
                productQueryForm.FormBorderStyle = FormBorderStyle.None;
                settingDic.Add("货品名称参数设置", productQueryForm);

                StackLocationQueryForm stackLocationQueryForm = new StackLocationQueryForm();
                stackLocationQueryForm.TopLevel = false;
                stackLocationQueryForm.Dock = DockStyle.Fill;//把子窗体设置为控件
                stackLocationQueryForm.FormBorderStyle = FormBorderStyle.None;
                settingDic.Add("库位参数设置", stackLocationQueryForm);

                #endregion
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }
    }
}
